package com.rongcheng.fortestlist;

import android.content.Context;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;

/**
 * @author frc
 *         created at 17-1-13.
 */

public class itemline extends Drawable {
    private Paint mPaint;
    private RectF rectF;
    Context context;

    public itemline(Context context) {
        mPaint = new Paint();
        this.context = context;
    }

    @Override
    public void draw(Canvas canvas) {
        Rect rect = getBounds();
        rect.left -= 1;
        rect.right += 1;
        rect.top = 0;
        rect.bottom = Utils.dip2px(context, 17);
        mPaint.setColor(ContextCompat.getColor(context, R.color.color_d65b4b));
        canvas.drawRect(rect, mPaint);
        mPaint.setColor(ContextCompat.getColor(context, R.color.color_999999));

        rect.top = Utils.dip2px(context, 17);
        rect.bottom = Utils.dip2px(context, 26);
        canvas.drawRect(rect, mPaint);
        mPaint.setColor(ContextCompat.getColor(context, R.color.color_d65b4b));

        rect.top = Utils.dip2px(context, 26);
        rect.bottom = Utils.dip2px(context, 44);
        canvas.drawRect(rect, mPaint);
        setBounds(0, 0, Utils.dip2px(context, 1), Utils.dip2px(context, 44));
    }

    @Override
    public void setAlpha(int i) {
        mPaint.setAlpha(i);
    }


    @Override
    public void setColorFilter(ColorFilter colorFilter) {
        mPaint.setColorFilter(colorFilter);
    }

    @Override
    public int getOpacity() {
        return PixelFormat.TRANSLUCENT;
    }
}
